package com.eastone.user.serverapi.service.impl;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.eastone.user.serverapi.dao.InfoAuthDao;
import com.eastone.user.serverapi.model.InfoAuth;
import com.eastone.user.serverapi.service.InfoAuthService;
import com.yjx.framework.cache.ServiceResultCodeCache;

import com.yjx.framework.model.ServiceResult;

@Service("infoAuthService")
public class InfoAuthServiceImpl implements InfoAuthService {
	@Autowired
	private InfoAuthDao infoAuthDao;
	private static ServiceResultCodeCache resultCode = ServiceResultCodeCache.getInstance();

	@Override
	public InfoAuth get(int id) {
		return infoAuthDao.get(id);
	}

	@Override
	public ServiceResult<String> add(InfoAuth infoAuth) {
		ServiceResult<String> serviceResult = new ServiceResult<String>();
		int result = infoAuthDao.add(infoAuth);
		if (result == 1) {
			serviceResult.setCode(resultCode.get("common.sucess"));
		} else {
			serviceResult.setCode(resultCode.get("common.fail"));
		}
		return serviceResult;
	}

	@Override
	public ServiceResult<String> addSelective(InfoAuth infoAuth) {
		ServiceResult<String> serviceResult = new ServiceResult<String>();
		int result = infoAuthDao.addSelective(infoAuth);
		if (result == 1) {
			serviceResult.setCode(resultCode.get("common.sucess"));
		} else {
			serviceResult.setCode(resultCode.get("common.fail"));
		}
		return serviceResult;
	}

	@Override
	public ServiceResult<String> update(InfoAuth infoAuth) {
		ServiceResult<String> serviceResult = new ServiceResult<String>();
		int result = infoAuthDao.update(infoAuth);
		if (result == 1) {
			serviceResult.setCode(resultCode.get("common.sucess"));
		} else {
			serviceResult.setCode(resultCode.get("common.fail"));
		}
		return serviceResult;
	}

	@Override
	public ServiceResult<String> updateSelective(InfoAuth infoAuth) {
		ServiceResult<String> serviceResult = new ServiceResult<String>();
		int result = infoAuthDao.updateSelective(infoAuth);
		if (result == 1) {
			serviceResult.setCode(resultCode.get("common.sucess"));
		} else {
			serviceResult.setCode(resultCode.get("common.fail"));
		}
		return serviceResult;
	}

	@Override
	public ServiceResult<String> delete(InfoAuth infoAuth) {
		ServiceResult<String> serviceResult = new ServiceResult<String>();
		int result = infoAuthDao.delete(infoAuth);
		if (result == 1) {
			serviceResult.setCode(resultCode.get("common.sucess"));
		} else {
			serviceResult.setCode(resultCode.get("common.fail"));
		}
		return serviceResult;
	}

	@Override
	public List<InfoAuth> getList(String name, String code, int pageNo, int pageSize) {
		return infoAuthDao.getList(name, code, pageNo, pageSize);
	}

	@Override
	public int getCount(String name, String code) {
		return infoAuthDao.getCount(name, code);
	}
}
